package com.gs.entity;


import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

@Data
public abstract class BaseEntity implements Serializable, Cloneable {

    @TableId
    @ApiModelProperty(value = "id",position = -1) // id永远显示在第一个
    private Long id;

    //逻辑删除标识字段 1:有效；0：无效
	@TableLogic(value = "1",delval = "0")   // value:默认值；delval：逻辑删除后的值
    @TableField(value = "data_status")
    @ApiModelProperty(hidden = true) // swagger里隐藏掉
    private Integer dataStatus = 1;

    //更新时间
//    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) 没有作用
//    @TableField(value = "update_time",update = "now()")
    @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE, update = "now()")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss") // 日期格式化
    @ApiModelProperty(hidden = true) // swagger里隐藏掉
    private LocalDateTime updateTime;

    // 乐观锁版本号
    @Version
    @TableField(value = "version",fill = FieldFill.INSERT_UPDATE)

    private Long version;

}